package com.tarena.lbs.test.basic.threadlocal;

import com.tarena.lbs.common.passport.enums.Roles;
import com.tarena.lbs.common.passport.principle.UserPrinciple;

public class MyFilter {
    private MyServlet myServlet=new MyServlet();
    public void doFilter(){
        UserPrinciple user=new UserPrinciple();
        user.setId(1);
        user.setRole(Roles.ADMIN);
        user.setNickname("王翠花");
        //线程上游 存储数据
        ThreadLocalUtils.set(user);
        myServlet.doGet();
        //线程数据使用结束 清空数据
        ThreadLocalUtils.clear();
    }
}
